<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/**
 * @OA\Schema(
 *     schema="SchoolResource",
 *     title="学校资源",
 *     description="学校信息",
 *     @OA\Property(property="id", type="integer", description="学校ID", example=1),
 *     @OA\Property(property="name", type="string", description="学校名称", example="示例学校"),
 *     @OA\Property(property="address", type="string", description="学校地址", example="北京市朝阳区xxx街道"),
 *     @OA\Property(property="tel", type="string", description="联系电话", example="010-12345678"),
 *     @OA\Property(property="memo", type="string", description="备注", example="学校备注信息"),
 *     @OA\Property(property="created_at", type="string", format="date-time", description="创建时间", example="2025-01-01 12:00:00"),
 *     @OA\Property(property="updated_at", type="string", format="date-time", description="更新时间", example="2025-01-01 12:00:00")
 * )
 */
class SchoolResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'address' => $this->address,
            'tel' => $this->tel,
            'memo' => $this->memo,
            'created_at' => $this->created_at?->toDateTimeString(),
            'updated_at' => $this->updated_at?->toDateTimeString(),
        ];
    }
} 